<template>
	<div>
		<headerNave :nva-datas="navDatas" v-on:backNav="backNav"></headerNave>
		<components :is="currentView" v-on:changeView="changeView" v-on:backPrev="backPrev" :template-obj="templateObj"></components>
	</div>
</template>
<script>
	import $ from 'jquery'
	import headerNave from '../../../../components/headerNave'
	import { GloabFun, Animation, HttpServer } from '../../../../assets/js/common.js'
	//统计列表
	const List = resolve => require(['./List.vue'], resolve)
	//统计图
	const Detail = resolve => require(['./Detail.vue'], resolve)
	//微图登录详情
	const WTLoginDetail = resolve => require(['./WTDetail/Detail-login.vue'], resolve)
	//微图借书详情
	const WTBorrowDetail = resolve => require(['./WTDetail/Detail-borrow.vue'], resolve)
	//微图还书详情
	const WTReturnDetail = resolve => require(['./WTDetail/Detail-return.vue'], resolve)
	//中控设备使用详情
	const TCDetail = resolve => require(['./TC1000Detail/Detail.vue'], resolve)
	//智能微图使用图标详情
	const WTChartDetail = resolve => require(['./WTChartDetail.vue'], resolve)
	export default {
		components: {
			List,
			Detail,
			headerNave,
			WTLoginDetail,
			WTBorrowDetail,
			WTReturnDetail,
			TCDetail,
			WTChartDetail
		},
		data() {
			return {
				currentView: "List",
				templateObj: {
					DistrictId: this.subArgs.DistrictId,
					CurrentView: this.subArgs.CurrentView
				},
				navDatas: [{
					name: '数据统计',
					view: ""
				}, {
					name: this.subArgs.CurrentView,
					view: "List"
				}]
			};
		},
		props: {
			subArgs: {
				type: Object,
				default: {}
			}
		},
		methods: {
			changeView(view, obj) {
				GloabFun.clearRecordPreview.call(this);
				obj.DistrictId = this.subArgs.DistrictId;
				obj.CurrentView = this.subArgs.CurrentView;
				Animation.animation($("#mainContent"), function() {
					if(obj) {
						this.navDatas = [{
							name: '数据统计',
							view: ""
						}, {
							name: this.subArgs.CurrentView,
							view: "List"
						}];
						this.templateObj = obj;
						if(view === "Detail") {
							this.navDatas.push({
								name: "在线时长详情",
								view: "Detail"
							});
						} else if(view === "WTChartDetail") {
							this.navDatas.push({
								name: "使用对比",
								view: "WTChartDetail"
							});
						}else if(view === "WTLoginDetail") {
							this.navDatas.push({
								name: "设备登录详情->" + obj.Name,
								view: "WTLoginDetail"
							});
						} else if(view === 'WTBorrowDetail') {
							this.navDatas.push({
								name: "设备借书详情->" + obj.Name,
								view: "WTBorrowDetail"
							});
						} else if(view === "WTReturnDetail") {
							this.navDatas.push({
								name: "设备还书详情->" + obj.Name,
								view: "WTReturnDetail"
							});
						} else if(view === "TCDetail") {
							this.navDatas.push({
								name: "设备使用详情->" + obj.Name,
								view: "TCDetail"
							});
						}
						// else if(view==="miniLibrary1Detail"){
						//   this.navDatas.push({
						//       name:obj.Title,
						//       view:"miniLibrary1Detail"
						//    });
						// }
					}
					this.currentView = view;
				}.bind(this));
			},
			backPrev() {
				this.$emit('backPrev');
			},
			backNav(item) {
				if(item.view === "List") {
					this.changeView("List", this.templateObj);
				}
			}
		}
	}
</script>